import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by abdulazizalonizi on 7/25/17.
 */
public class Task5 {
    public static void main (String[] args)
    {
        boolean flag = true;

        double Score = 0 ;
        double scores = 0;
        int count = 0;
        String id = null;
       // FileOutputStream fosG =null;
        //FileOutputStream fosP =null;

        try {
            FileOutputStream fosG = new FileOutputStream("Good1.txt");
            PrintWriter pwG = new PrintWriter(fosG);

            FileOutputStream fosP = new FileOutputStream("Poor1.txt");
            PrintWriter pwP = new PrintWriter(fosP);

            FileInputStream fis = new FileInputStream("inputScores.txt");
            Scanner fi = new Scanner(fis);

            while(fi.hasNext())
            {
                id = fi.next();
                scores = scores + fi.nextDouble();
                count++;

            }
            fis.close();
            double avg = scores/count;
            System.out.println(avg);

            FileInputStream fis2 = new FileInputStream("inputScores.txt");
            Scanner fi2 = new Scanner(fis2);

            while(fi2.hasNext())
            {
                id = fi2.next();
                Score =  fi2.nextDouble();
                System.out.println(id  + " "+Score);

                if (Score >= avg )
                {
                    pwG.println(id + "      "+Score);

                }
                else
                {
                    pwP.println(id + "      "+Score);
                }


            }
           pwG.close();
            pwP.close();
        }
        catch(Exception me)
        {

            System.out.println("exception found !");
        }


        }



    }

